package com.agritech.service.impl;

import com.agritech.entity.Answer;
import com.agritech.mapper.AnswerMapper;
import com.agritech.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 回答服务实现类
 */
@Service
public class AnswerServiceImpl implements AnswerService {
    
    @Autowired
    private AnswerMapper answerMapper;
    
    @Override
    public List<Answer> getAnswersByQuestionId(Long questionId) {
        return answerMapper.selectByQuestionId(questionId);
    }
    
    @Override
    public Answer getAnswerById(Long id) {
        return answerMapper.selectById(id);
    }
    
    @Override
    public boolean addAnswer(Answer answer) {
        int result = answerMapper.insert(answer);
        return result > 0;
    }
    
    @Override
    public boolean updateAnswer(Answer answer) {
        int result = answerMapper.update(answer);
        return result > 0;
    }
}    